package cn.jbt.api.admin.entity.dto;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResetPassDTO {

    @NotNull(message = "用户ID不能为空")
    private Long id;

    @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])(.{8,16})$", message = "新的密码必须8-16位，并且包含字母、数字、特殊字符")
    @NotBlank(message = "新的密码不能为空")
    private String newPass;

    @Pattern(regexp = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])(.{8,16})$", message = "再次密码必须8-16位，并且包含字母、数字、特殊字符")
    @NotBlank(message = "再次密码不能为空")
    private String againPass;

    public void validate() {
        if (!newPass.equals(againPass)) {
            throw new RuntimeException("新的密码和再次密码不一致");
        }
    }

}
